'''
    调用Base页
'''
import time

from month.Base.Base import Base
from selenium.webdriver.common.by import By
class Page(Base):
    # 定位 登录按钮
    bd_login_loc = (By.ID,'s-top-loginbtn')
    def bd_login(self):
        self.click(self.bd_login_loc)
    #输入账号
    username_loc = (By.XPATH,'/html/body/div[5]/div[2]/div[2]/div/div/div/div/div/div[1]/div[2]/form/p[3]/input[2]')
    def username(self,username):
        self.send_keys(self.username_loc,username)
    # 输入密码
    password_loc = (By.XPATH,'//input[@id="TANGRAM__PSP_11__password"]')
    def password(self,password):
        self.send_keys(self.password_loc,password)

    # 勾选协议
    xy_loc = (By.NAME,'isAgree')
    def xy(self):
        self.click(self.xy_loc)

    # 点击登录按钮
    but_login_loc = (By.ID,'TANGRAM__PSP_11__submit')
    def but_login(self):
        self.click(self.but_login_loc)
    # 断言
    dy1_loc = (By.ID, 'TANGRAM__PSP_11__changePwdCodeItem')
    def dy1(self):
        return self.text(self.dy1_loc)

    def baidu_login_001(self,password,username):
        self.open_url('https://www.baidu.com/')
        self.bd_login()
        time.sleep(5)
        print(self.dy1())
        try:
            assert '账号登录' == self.dy1()
        except Exception as e:
            print(e)
            self.driver.save_screenshot('a.png')
        self.username(username)
        self.password(password)
        self.xy()
        self.but_login()